<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title>主页</title>
<%@include file="common/inc.jsp"%>
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/resource/css/home.css">
<script type="text/javascript">
	var mainMenu;
	var mainTabs;
	$(function() {
		mainMenu = $("#mainMenu").tree({
			url:"<%=request.getContextPath()%>/resourceController/tree",
			parentField:"pid",
			onClick:function(node){
				var src = "<%=request.getContextPath()%>" + node.attributes.url;
								if (!sy.startWith(node.attributes.url, '/')) {
									src = node.attributes.url;
								}
								if (node.attributes.target
										&& node.attributes.target.length > 0) {
									window.open(src, node.attributes.target);
								} else {
									var tabs = $('#mainTabs');
									var opts = {
										title : node.text,
										closable : true,
										iconCls : node.iconCls,
										content : sy
												.formatString(
														'<iframe src="{0}" allowTransparency="true" style="border:0;width:100%;height:99%;" frameBorder="0"></iframe>',
														src),
										border : false,
										fit : true
									};
									if (tabs.tabs('exists', opts.title)) {
										tabs.tabs('select', opts.title);
									} else {
										tabs.tabs('add', opts);
									}
								}
							}
						});
		mainTabs = $('#mainTabs').tabs({
			fit : true,
			border : false,
			tools : [ {
				iconCls : 'ext-icon-arrow_up',
				handler : function() {
					mainTabs.tabs({
						tabPosition : 'top'
					});
				}
			}, {
				iconCls : 'ext-icon-arrow_left',
				handler : function() {
					mainTabs.tabs({
						tabPosition : 'left'
					});
				}
			}, {
				iconCls : 'ext-icon-arrow_down',
				handler : function() {
					mainTabs.tabs({
						tabPosition : 'bottom'
					});
				}
			}, {
				iconCls : 'ext-icon-arrow_right',
				handler : function() {
					mainTabs.tabs({
						tabPosition : 'right'
					});
				}
			}, {
				text : '刷新',
				iconCls : 'ext-icon-arrow_refresh',
				handler : function() {
					var panel = mainTabs.tabs('getSelected').panel('panel');
					var frame = panel.find('iframe');
					try {
						if (frame.length > 0) {
							for (var i = 0; i < frame.length; i++) {
								frame[i].contentWindow.document.write('');
								frame[i].contentWindow.close();
								frame[i].src = frame[i].src;
							}
							if (navigator.userAgent.indexOf("MSIE") > 0) {// IE特有回收内存方法
								try {
									CollectGarbage();
								} catch (e) {
								}
							}
						}
					} catch (e) {
					}
				}
			}, {
				text : '关闭',
				iconCls : 'ext-icon-cross',
				handler : function() {
					var index = mainTabs.tabs('getTabIndex', mainTabs.tabs('getSelected'));
					var tab = mainTabs.tabs('getTab', index);
					if (tab.panel('options').closable) {
						mainTabs.tabs('close', index);
					} else {
						$.messager.alert('提示', '[' + tab.panel('options').title + ']不可以被关闭！', 'error');
					}
				}
			} ]
		});
	})
</script>
</head>
<body class="easyui-layout">
	<div data-options="region:'north',border:false"
		style="height: 60px; background: #B3DFDA; padding: 10px">north
		region</div>

	<div data-options="region:'west',split:true,title:'功能导航'"
		style="width: 150px; padding: 10px;">
		<ul id="mainMenu"></ul>
	</div>

	<div data-options="region:'south',border:false"
		style="height: 30px; background: #A9FACD; padding: 10px;">@copy;版权所有</div>
	
	<div data-options="region:'center'">
		<div id="mainTabs">
			<div title="欢迎页面" data-options="iconCls:'ext-icon-heart'">
				<iframe src="" allowTransparency="true"
					style="border: 0; width: 100%; height: 99%;" frameBorder="0"></iframe>
			</div>
		</div>

	</div>
</body>
</html>